package net.lulihu.common_util.exception;

import net.lulihu.exception.ExceptionEnum;

/**
 * 常规业务异常枚举
 * <p>
 * 从错误代码1000开始，依次递增
 * <p>
 * http代码将 https://tools.ietf.org/html/rfc7231#section-6.5.8
 * <p>
 * 自定义错误http code 555
 * 自定义错误消息code  999
 * <p>
 * {}为占位符可以进行值替换
 */
public enum BusinessExceptionEnum implements ExceptionEnum {

    /* ******** 错误异常 ********  */
    EXPECTED_TIMED_ERROR(408, 1000, "预期之外的超时响应，请刷新后重试！"),
    EXPECTED_ERROR(500, 1001, "预期之外的错误，请稍后重试！"),
    ILLEGAL_OPERATION(406, 1002, "预期之外的操作，无法执行!"),
    SERVICE_IS_NOT_AVAILABLE(503, 1019, "服务不可用，请稍后重试"),

    /* ******** 错误的请求 ********  */
    REQUEST_NULL(400, 1003, "无法解析请求,请检查参数!"),
    INVALID_DATE_STRING(400, 1004, "日期格式无法匹配，请检查!"),
    PARAM_NOT_REQUIRE(400, 1005, "参数不合法,请检查后重试!"),
    HTTP_MESSAGE_NOT_READABLE(400, 1006, "HTTP消息不可读"),
    NO_FOUND(404, 1007, "请求地址不存在"),

    /* ******** 访问错误 ********  */
    TOKEN_ABNORMAL(403, 1008, "Token异常，请重新登录"),
    NO_API_ACCESS(403, 1009, "无接口访问权限"),
    NO_PLATFORM_ACCESS(403, 1010, "无平台访问权限"),
    API_OFFLINE(410, 1011, "接口已下线"),
    WRONG_SERVICE_KEY(403, 1012, "错误的服务秘钥"),
    USER_PERMISSION_IS_ABNORMAL(403, 1013, "用户权限异常，请重新登录"),
    WRONG_PLATFORM_KEY(400, 1014, "错误的平台秘钥"),
    USER_DOES_NOT_EXIST(302, 1015, "用户不存在"),
    USER_NOT_HAVE_ROLE_ON_SPECIFIED_SERVICE_PLATFORM(302, 1016, "用户在指定服务平台不存在角色"),
    USER_FORBIDDEN_TO_LOG_IN(403, 1017, "用户被禁止登录"),
    WRONG_RESOURCE_REQUEST_VALUE(400, 1018, "错误的资源请求值【{}】"),
    USER_NOT_SPECIFY_TYPE_RESOURCE_PERMISSION(302, 1019, "用户没有指定类型资源权限，鉴权失败"),
    USER_NOT_SPECIFY_RESOURCE_PERMISSIONS(302, 1020, "用户没有资源【{}】的权限，鉴权失败"),
    ACCESS_PASS_NOT_EXIST(403, 1021, "访问通行证不存在"),
    ACCESS_PASS_HAS_EXPIRED(403, 1022, "访问通行证已过期"),
    ACCESS_PASS_HAS_BEEN_OVERLOADED(403, 1022, "访问通行证已超载"),
    NOT_HAVE_MODULE_PERMISSIONS_ON_SPECIFIED_SERVICE_PLATFORM(302, 1023, "用户在指定服务平台不存在模块权限"),
    API_ADDRESS_DOES_NOT_EXIST(302, 1024, "接口地址不存在"),
    ;

    BusinessExceptionEnum(Integer httpCode, Integer code, String message) {
        this.httpCode = httpCode;
        this.code = code;
        this.message = message;
    }

    private Integer httpCode;

    private Integer code;

    private String message;

    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

}
